#ifndef TOOLBUTTON_H
#define TOOLBUTTON_H

#include <QGraphicsPixmapItem>
#include <QGraphicsScene>
#include <QGraphicsRectItem>
#include <QGraphicsTextItem>
#include <QPixmap>
#include <QApplication>
#include <QPainter>
#include <QFont>
#include <QGraphicsSceneHoverEvent>

#define RESOURCE_DIR QApplication::applicationDirPath() + "/../../resources"

class ToolButton : public QObject, public QGraphicsPixmapItem
{
    Q_OBJECT

public:
    ToolButton(QGraphicsScene * scene);
    ToolButton(QString caption, QPixmap icon, QGraphicsScene * scene);

    ~ToolButton();

    void setIcon(QPixmap icon);
    void setToggleButton(bool toggle);
    bool isToggleButton();
    bool getSate();

signals:
    void clicked(ToolButton * sender);

public slots:
    void releaseButton();

protected:
    void mousePressEvent(QGraphicsSceneMouseEvent *event);
    void mouseReleaseEvent(QGraphicsSceneMouseEvent *event);

    void hoverEnterEvent(QGraphicsSceneHoverEvent *event);
    void hoverLeaveEvent(QGraphicsSceneHoverEvent *event);
    void hoverMoveEvent(QGraphicsSceneHoverEvent *event);

private:
    QGraphicsPixmapItem * iconItem;
    QPixmap buttonUp, buttonDown;

    QGraphicsRectItem * toolTip;
    QGraphicsTextItem * toolTipText;

    bool buttonState;
    bool toggleButton;
};

#endif // TOOLBUTTON_H
